﻿@extends('common.header')

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ $category_info->title }}{{ $webConfig->webName }}</title>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="white">
    <meta name="Keywords" content="{{ $category_info->keywords }}"/>
    <meta name="Description" content="{{ $category_info->desc }}"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="csrf-token" content="{{ csrf_token() }}">
	<link rel="shortcut icon" href="{{ asset('/images/favicon.ico') }}" />
    <link rel="stylesheet" type="text/css" href="{{ asset('/css/newList/info_list.css') }}"/>
    <script src=" {{ asset('/js/jquery-1.8.3.min.js') }} "></script>
    <script type='text/javascript'>

        <!-- 2.设置全局ajax选项 -->
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        // 获取 token
        var _token = $('meta[name="csrf-token"]').attr('content');

        // 点赞
        function replyPraise(prefix, id, likeType) {
            var obj = $("#" + prefix + "_praise_" + id);
            var isPraise = obj.attr('isPraise');
            if (isPraise == 'false') {
                // 未点赞
                // 获取 现有 赞数
                var num = parseInt($("#" + prefix + "_praise_txt_" + id).text());
                // +1
                num += 1;
                $("#" + prefix + "_praise_txt_" + id).text(num);
                // 已赞图片
                $("#" + prefix + "_praise_img_" + id).attr("src", "{{ asset('/images/articles/yizan.png') }}");
                // 写进 数据库
                $.ajax({
                    type: "post",
                    url: "{{ url('/commentLike') }}/" + likeType,
                    data: {id: id, _token: _token},
                    async: false,
                    dataType: "json",
                    success: function (back) {
                        // alert(back['show_info']);
                    }
                });
                // 设置为 已点赞
                obj.attr('isPraise', 'true');

            } else {
                // 已点赞
                $("#" + prefix + "_warn_" + id).html('');
                $("#" + prefix + "_warn_" + id).html('您已赞过');
                $("#" + prefix + "_warn_" + id).show();
                setTimeout(function () {
                    $("#" + prefix + "_warn_" + id).hide();
                }, 1000);
            }

        }
    </script>
    <script>

        // 收藏
        function collect(prefix, id, collectType) {
            var obj = $("#" + prefix + "_collect_" + id);
            var isCollect = obj.attr('isCollect');
            if (isCollect == 'false') {
                // 未收藏

                // 写进 数据库
                $.ajax({
                    type: "post",
                    url: "{{ url('/collect') }}/" + collectType,
                    data: {id: id, _token: _token},
                    async: false,
                    dataType: "json",
                    success: function (back) {

                        if (back['show_info'] != '') {
                            $("#" + prefix + "_warn_" + id).html('');
                            $("#" + prefix + "_warn_" + id).html('您已收藏过');
                            $("#" + prefix + "_warn_" + id).show();
                            setTimeout(function () {
                                $("#" + prefix + "_warn_" + id).hide();
                            }, 1000);
                            // 已收藏图片
                            $("#" + prefix + "_collect_img_" + id).attr("src", "{{ asset('/images/articles/yicang.png') }}");

                        } else {
                            $("#" + prefix + "_warn_" + id).html('');
                            $("#" + prefix + "_warn_" + id).html('收藏成功');
                            $("#" + prefix + "_warn_" + id).show();
                            setTimeout(function () {
                                $("#" + prefix + "_warn_" + id).hide();
                            }, 1000);
                            // 已收藏图片
                            $("#" + prefix + "_collect_img_" + id).attr("src", "{{ asset('/images/articles/yicang.png') }}");
                        }

                    }
                });
                // 设置为 已收藏
                obj.attr('isCollect', 'true');

            } else {
                $("#" + prefix + "_warn_" + id).html('');
                $("#" + prefix + "_warn_" + id).html('您已收藏过');
                $("#" + prefix + "_warn_" + id).show();
                setTimeout(function () {
                    $("#" + prefix + "_warn_" + id).hide();
                }, 1000);
                // 已收藏图片
                $("#" + prefix + "_collect_img_" + id).attr("src", "{{ asset('/images/articles/yicang.png') }}");

            }

        }
		
		function tag(tag_name)
		{
			// 表单设置好值
			$("input[name='tag']").attr('value',tag_name);
			// 提交表单
			$("#tagForm").submit();
		}


    </script>
</head>
<body style="background:#fff">
<!--面包屑导航-->
<div style="width: 1200px;height: 40px;line-height:40px;position: relative;margin: 110px auto 0">
    <ol style="float: left;overflow: hidden;color: #333;list-style: none;">
        <li style="float: left;margin-left: 5px">当前位置：</li>
        <li style="float: left;margin-left: 5px"><a href="{{ url('/') }}"
                                                                      style="color: #de1e30;margin-left: 5px">首页</a>
        </li>
        <li style="float: left;margin-left: 5px"><a href="{{ url('/newsList/all/tag') }}"
                                                                      style="color: #de1e30;margin-left: 5px">> 资讯列表</a>
        </li>
        <li style="float: left;margin-left: 5px">> {{ $category_info->name }}</li>
    </ol>
</div>


<!-- 情报中心菜单 -->
<div class="info-nav-big">
    <div class="info-nav-kuang">

        <div class="info-nav">
            <ul class="info-nav-list wrap">
                @if( $category_id=='all' )
					<li class="current-info">
						<a href="{{ url('/newsList/all/tag') }}">全部</a>
						<i></i>
					</li>
					@forelse( $news_category as $key => $category_info )
					<li>
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
					</li>
					@empty
					@endforelse
                @elseif( $category_id=='2' )
					<li>
						<a href="{{ url('/newsList/all/tag') }}">全部</a>
						<i></i>
					</li>
					@forelse( $news_category as $key => $category_info )
					@if( $category_info->id=='2' )
					<li class="current-info">
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@else
					<li>
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
					</li>
					@endif
					@empty
					@endforelse
                @elseif( $category_id=='3' )
					<li>
						<a href="{{ url('/newsList/all/tag') }}">全部</a>
						<i></i>
					</li>
					@forelse( $news_category as $key => $category_info )
					@if( $category_info->id=='3' )
					<li class="current-info">
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@else
					<li>
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@endif
					@empty
					@endforelse
                @elseif( $category_id=='4' )
					<li>
						<a href="{{ url('/newsList/all/tag') }}">全部</a>
						<i></i>
					</li>
					@forelse( $news_category as $key => $category_info )
					@if( $category_info->id=='4' )
					<li class="current-info">
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@else
					<li>
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@endif
					@empty
					@endforelse
                @elseif( $category_id=='5' )
					<li>
						<a href="{{ url('/newsList/all/tag') }}">全部</a>
						<i></i>
					</li>
					@forelse( $news_category as $key => $category_info )
					@if( $category_info->id=='5' )
					<li class="current-info">
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@else
					<li>
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@endif
					@empty
					@endforelse
                @elseif( $category_id=='6' )
					<li>
						<a href="{{ url('/newsList/all/tag') }}">全部</a>
						<i></i>
					</li>
					@forelse( $news_category as $key => $category_info )
					@if( $category_info->id=='6' )
					<li class="current-info">
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@else
					<li>
						<a href="{{ url('/newsList') }}/{{ $category_info -> id }}/tag">{{ $category_info -> name }}</a>
						<i></i>
					</li>
					@endif
					@empty
					@endforelse
                @else
                @endif
            </ul>
        </div>
		<form  method="post" action="{{ url('/newsList') }}" id="tagForm" >
			{{ csrf_field() }}	
			<input type="hidden" name="tag" value="" />
		</form>
        <!-- 关键字搜索
        <div class="info-nav-keyword">
            @if( $category_id > 0 )
            <form class="club-tit-a3" method="post" action="{{ url('/news/list') }}/{{ $category_id }}">
            @else
            <form class="club-tit-a3" method="post" action="{{ url('/news/list') }}">
            @endif
                    {{ csrf_field() }}
                    <input type="text" name="keyTitle" placeholder="输入资讯标题进行搜索" value="{{ $keyTitle or '' }}"/>
                    <button type="submit">搜索</button>
                </form>
        </div> -->
    </div>
</div>

<!-- 情报中心新闻 -->
<div class="info-area-big">
    <div class="info-area">
        <!--右侧新闻推荐列表-->
        <div class="info-ranking-list">
            <div class="hotvideo">
                <div class="hottitle">热门资讯</div>
                <div class="hotlist">
                    <ul id="hotNew">
                        <!--热门资讯列表-->
                        @forelse( $recommend as $key=>$recommend_info)
                        @if( $key==0 )
                        <li>
							<div class="hotlist_box hotlist_div on">
								<div class="hotimg">
									<img src="{{ $recommend_info['pic_url'] }}" alt="{{ $recommend_info['title'] }}" />
								</div>
								<div class="hotrtext comtext"><p> <a href="{{ url('/news') }}/{{ $recommend_info['id'] }}" class="leftlist_a" alt="{{ $recommend_info['title'] }}" >{{ $recommend_info['title'] }}</a></p></div>
							</div>
                            
                        </li>
                        @else
                        <li>
                            
							<div class="hotlist_box" id="add">
								<div class="hotimg">
									<img src="{{ $recommend_info['pic_url'] }}" alt="{{ $recommend_info['title'] }}" />
								</div>
								<div class="hotrtext comtext"><p><a href="{{ url('/news') }}/{{ $recommend_info['id'] }}" class="leftlist_a">{{ $recommend_info['title'] }}</a></p></div>
							</div>
                           
                        </li>
                        @endif
                        @empty
                        @endforelse
                    </ul>
                </div>
            </div>
        </div>
        <!--左侧新闻列表-->
        <div class="info-list" style="border:none">
            <!--一项 新闻-->
            @forelse( $page_news as $key => $news_info )
            <div class="info-news">
                <a href="{{ url('/news') }}/{{ $news_info['id'] }}" class="news-img" target="_blank">
                    <img src="{{ $news_info['pic_url'] }}" alt="{{ $news_info['title'] }}" title="{{ $news_info['title'] }}" />
                </a>
                <a href="{{ url('/news') }}/{{ $news_info['id'] }}" ><h3>{{ $news_info['title'] }}</h3></a>
                <div class="info-list-content">
                    {!! $news_info['content'] !!}
                </div>
                <div class="time-more">
                    <span class="time"><i>{{ $news_info['create_time'] }}</i></span>
                    @if( $news_info['from'] )
                    <span class="time">来自<i>{{ $news_info['from'] }} </i></span>
                    @else
                    @endif
					<span class="time" style="float:right;"><a href="{{ url('/news') }}/{{ $news_info['id'] }}" style="color: #777;">全文阅读</a></span>

                    <div class="info-tip">
                        <a href="{{ url('/newsList') }}/{{ $news_info['category_id'] }}/tag">{{ $news_info['category']
                            }}</a>
                    </div>
                </div>
                <div class="info-list-bottom">
                    <u></u>
                    <div class="info-label">
							<span>标签：
							<i>
								<!--&nbsp;&nbsp;<span onclick="tag('{{ 'tagname' }}');" style="cursor:pointer;" >{{ 'tagname' }}</span>-->
								@forelse( $news_info['tags'] as $tag_name )
									&nbsp;&nbsp;<a href="{{ url('/newsList') }}/{{ $category_id }}/tag/{{ $tag_name['tag_id'] }}">{{ $tag_name['name'] }}</a>
								@empty
								@endforelse
							<i>
							</span>

                    </div>
                    <span id="news_warn_{{ $news_info['id'] }}"
                          style="margin-left:512px;line-height: 48px;height:60px;display:inline-block;"></span>
                    <div class="share-box">

                        <!-- 点赞 -->
                        <div class="first-boy praise">
                            <a>
								<span id="news_praise_{{ $news_info['id'] }}"
                                      onclick="replyPraise( 'news',{{ $news_info['id'] }},1);" isPraise="false"
                                      style="padding-top:-6px;display:inline-block;">
									<img src="{{ asset('/images/articles/zan.png') }}" alt=""
                                         id="news_praise_img_{{ $news_info['id'] }}">
								</span>
                                <span id="news_praise_txt_{{ $news_info['id'] }}">{{ $news_info['good'] }}</span>

                            </a>
                        </div>

                        <!-- 评论 -->
                        <div class="first-boy praise">
                            <a href="{{ url('/news') }}/{{ $news_info['id'] }}">
							<span style="padding-top:-6px;display:inline-block;">
									<img src="{{ asset('/images/articles/ping.png') }}" alt="">
								</span>
                                <span>{{ $news_info['comments_total'] }}</span>
                            </a>
                        </div>

                        <!-- 收藏 -->
                        <div class="first-boy praise">
                            <a>
                                @if( session('user_name') )
                                <span id="news_collect_{{ $news_info['id'] }}"
                                      onclick="collect('news',{{ $news_info['id'] }},1);"
                                      style="padding-top:-6px;display:inline-block;" isCollect='false'>
										<img src="{{ asset('/images/articles/cang.png') }}"
                                             id="news_collect_img_{{ $news_info['id'] }}">
									</span>
                                @else
                                <span id="collectLogin">
									<img src="{{ asset('/images/articles/cang.png') }}"/>
								</span>
                                @endif

                            </a>
                        </div>

                    </div>

                </div>
            </div>
            @empty
            <!--没有文章时显示-->
            <div class="none_article">
                <img src="{{ asset('/images/articles/nothing.png') }}" alt="">
                <p>没有发现文章！ </p>
            </div>
            @endforelse
        </div>
    </div>
</div>

<!-- 分页 -->
<div style="width:70%;text-align:center;font-size:14px;">
    {{ $all_news-> appends(['keyTitle'=>$keyTitle]) ->links() }}
</div>


@extends('common.footer')
</body>
</html>